﻿using System;
using ContractManagementSystem.BusinessLogic;

namespace ContractManagementSystem
{
    public partial class LogOn : System.Web.UI.Page
    {
        protected void SubmitButtonClick(object sender, EventArgs e)
        {
            var name = UserNameTextBox.Text.Trim();
            var pass = PasswordTextBox.Text.Trim();

            if(!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(pass))
            {
                if (UserBusiness.CheckLogOn(UserNameTextBox.Text, PasswordTextBox.Text))
                {
                    Session["Name"] = name;
                    Session["UserId"] = UserBusiness.FetchByExactUserName(name).Rows[0][0];
                    Response.Redirect("Default.aspx");
                }
            }

        }
    }
}
